const { batchUploadToCOS } = require('../utils/cosClient');

exports.batchUpload = async (req, res) => {
  const bodyReq = req.body;
  // console.log(bodyReq.appId,'batchUpload')
  try {
    if (!req.files || req.files.length === 0) {
      return res.status(400).json({ 
        success: false,
        message: '没有上传文件' 
      });
    }
    
    // 上传文件到腾讯云COS
    const results = await batchUploadToCOS(req.files,bodyReq.appId);
    
    res.json({
      success: true,
      results: results,
      status:200
    });
  } catch (error) {
    console.error('上传到COS失败:', error);
    res.status(500).json({
      success: false,
      message: '文件上传失败',
      error: error.message
    });
  }
};